﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using AutoMapper;

namespace SPContrib.TypeConverters
{
    public class XmlNodeToXElement : TypeConverter<XmlNode, XElement>
    {
        protected override XElement ConvertCore(XmlNode source)
        {
            XDocument xd = new XDocument();

            using (XmlWriter xw = xd.CreateWriter())
            {
                source.WriteTo(xw);
            }

            return xd.Root;
        }
    }
}
